#ifndef _AIS_PROTOCOL_H_
#define _AIS_PROTOCOL_H_

/*******************************************************************
 *
 * Copyright (C), 2021-2022, Letstrong, All rights reserved.
 *
 * Author      : 
 * Create Time : 2020-01-05
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
/*----------------------------Head file----------------------------*/
#include "stdint.h"
#include "stdbool.h"

/*----------------------------macro file---------------------------*/
#define AIS_MSG_ID_MAX_NUM			15
#define AIS_FRAME_MAX_NUM			15
#define AIS_FRAME_DATA_MAX_SIZE		16

#define AIS_ACK						0x01

#define AIS_RESULT_SUCCESS			0x00
#define AIS_RESULT_FAIL				0x01

#define AIS_UNBIND					0x00
#define AIS_BIND_DONE				0x01

#define AIS_CMD_DEV_UPLOAD			0x01
#define AIS_CMD_APP_REQ				0x02
#define AIS_CMD_DEV_RSP_REQ			0x03
#define AIS_CMD_DEV_REQ				0x04
#define AIS_CMD_APP_RSP_REQ			0x05
#define AIS_CMD_ERR_UPLOAD			0x0F
#define AIS_CMD_APP_AUTH_RANDOM		0x10
#define AIS_CMD_DEV_AUTH_CIPHER		0x11
#define AIS_CMD_APP_AUTH_RESULT		0x12
#define AIS_CMD_DEV_AUTH_RESULT		0x13
#define AIS_CMD_APP_BIND_OP			0x14
#define AIS_CMD_DEV_BIND_OP			0x15


#define OP_VENDER_MSG_ATTR_GET				0xD0
#define OP_VENDER_MSG_ATTR_SET				0xD1
#define OP_VENDER_MSG_ATTR_SET_UNACK		0xD2
#define OP_VENDER_MSG_ATTR_STATUS			0xD3
#define OP_VENDER_MSG_ATTR_INDICATION		0xD4
#define OP_VENDER_MSG_ATTR_CFM				0xD5
#define OP_VENDER_MSG_ATTR_IND_TO_TMG		0xDE
#define OP_VENDER_MSG_ATTR_CFM_FROM_TMG		0xDF
#define OP_VENDER_MSG_ATTR_TRANSP_MSG		0xCF

/*----------------------------type define--------------------------*/
#pragma pack(1)

typedef struct {
	struct {
		uint8_t id	 			:4;
		uint8_t security		:1;
		uint8_t version			:3;
	} msg;

	uint8_t cmd;

	struct {
		uint8_t seq	 			:4;
		uint8_t total_num		:4;
	} frame;

	uint8_t frame_len;
	uint8_t data[AIS_FRAME_DATA_MAX_SIZE];
} ais_frame_t;

typedef struct {
	uint8_t mode;
	uint8_t trip_num;
	uint16_t sport_time;
	uint16_t sport_count;
	uint16_t max_num_consecutive;
	uint16_t highest_freq;
	uint16_t avg_freq;
} ais_skip_ret_t;

#pragma pack()

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/
extern void ais_upload_skip_disp_data(void);
extern void ais_upload_skip_result(void);
extern void ble_ais_client_write_handle(const uint8_t *pData, uint8_t len);

/*-----------------------------------------------------------------*/

#endif
